class MyInheritableThreadLocalExample {
    private static ThreadLocal<Integer> threadLocal = new InheritableThreadLocal<>();

    public static void main(String[] args) {
        // 设置线程局部变量的值
        threadLocal.set(123);

        // 创建子线程并执行任务
        Thread childThread = new Thread(() -> {
            // 子线程可以继承父线程的线程局部变量的值
            int value = threadLocal.get();
            System.out.println("子线程获取到的值：" + value);
            for (int i = 0; i < 100; i++) {
                System.out.println(i);
            }
        });
        childThread.start();

        System.out.println("aaaaaaaend");


    }
}